{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d4c901de",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2 as cv\n",
    "import numpy as np\n",
    "\n",
    "img = cv.imread('../data/sudoku.png',0)\n",
    "equ = cv.equalizeHist(img)\n",
    "res = np.hstack((img,equ)) #stacking images side-by-side\n",
    "# cv.imwrite('res.png',res)\n",
    "\n",
    "cv.imshow(\"res\", res)\n",
    "cv.waitKey(0)\n",
    "\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "e98c2ce2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAWGUlEQVR4nO3dYYxdZ33n8e+vhoSqsE1CRlHWttYu9aoKlTDRbMgKhFgQiWNWa5BaFLQqForkVnIkULu7OO2LUNhIYbWQLRJEMo0XU7GkUQHFgmxTNwShviDJhBoTJ5vNQIJiy8RTEgIINbtJ//viPmYvzoznzsyde+fe8/1IoznnOefc+zw+17/7zHOee0+qCklSN/zKuCsgSRodQ1+SOsTQl6QOMfQlqUMMfUnqkFeMuwLnc+mll9a2bdvGXQ1JmigPP/zwP1TVzGLbNnTob9u2jbm5uXFXQ5ImSpIfLLXN4R1J6hBDX5I6xNCXpA4x9CWpQwx9SeoQQ1+SOsTQl6QOMfQlqUMMfUnqEENfE23bga+NuwrSRDH0JalDDH1J6hBDX5I6ZODQT7Ipyd8n+Wpb357kgSTzSf4yyQWt/MK2Pt+2b+t7jJta+eNJrh16ayRJ57WSnv4Hgcf61j8O3FZVvwk8B9zQym8Anmvlt7X9SHIFcD3wemAX8Jkkm9ZWfUnSSgwU+km2AO8C/rytB3g78Fdtl8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C4bT9XWxVJtm+bzfWMb0jjUN1Q3Ne1Nsg14I/AAU35+z2krjPHcTmPod8VbqupK4Dpgf5K39m+s3t+LUzkfd5rb1ud24HXATuA08Imx1mbIkrwa+BLwoar6Sf+2aTu/i7R1rOd2GkO/E1/1UFWn2u8zwFfo/Rn4zNk/fdvvM+Or4dAt1bapPN9V9UxVvVRV/wR8lv//Z/7EtzfJK+mF4Beq6suteCrP72JtHfe5ncbQn/qvekjya0lec3YZuAZ4hF4797bd9gJ3j6eG62Kpth0B3t9meVwNPN83TDCxzhm3fg+98wu99l6f5MIk24EdwIOjrt9qJQlwB/BYVX2yb9PUnd+l2jr2czvuK9zrdNV8N70r5d8D/mTc9VmH9v0Gvav83wFOnG0j8FrgPuAJ4G+BS8Zd11W274v0/uz9v/TGNW9Yqm30ZnV8up3r7wKz467/kNr7F609x1sYXN63/5+09j4OXDfu+q+wrW+hN3RzHDjWfnZP4/k9T1vHem79GgZJ6pBpHN6RJC3B0JekDjH0JalDDH1J6hBDX5I6xNCXpA4x9CWpQ/4fB1p2tji9em4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAVe0lEQVR4nO3df4xdZ33n8fen+UVV2MYhs1FqW2uXuluZlTCRN2QFqmgiEses1kGiKKgiFkrllTaRYNvdrbP9IxQaCapCdqOlkczGi1NR0qiAYkGW1IRUqH8k8YQaJ06azZAExZaJpzgEKtTsJnz3j/sYLmZ+3Jm5M3fmnvdLGs0533POvc8zZ+Zzz33OuXNSVUiSuuEXRt0ASdLKMfQlqUMMfU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vfdgF3V8/DwIVJLl2Rhg7JLP2dzS7gnqp6paqeA6bo/c6vCVV1sqq+2aZ/CDwFrGcM9+8cfZ3NiuzbcQz99cALffPHmfsHvVYV8NdJHmv/ugLgkqo62aa/C1wymqYti9n6Ns77++Y2pLG/b6hubPqbZBPwVuARxnz/ntVXGOG+HcfQ74p3VNVl9P5j6U1JfrN/YfXeL47l9bjj3Lc+dwJvArYBJ4FPjrQ1Q5bk9cAXgA9X1Q/6l43b/p2hryPdt+MY+p34Vw9VdaJ9PwV8id7bwBfPvPVt30+NroVDN1vfxnJ/V9WLVfVaVf0Y+Aw/fZu/5vub5Dx6Ifi5qvpiK4/l/p2pr6Pet+MY+mP/rx6S/FKSN5yZBq4GnqDXz91ttd3AfaNp4bKYrW8HgRvaVR5XAC/3DROsWWeNW7+H3v6FXn+vT3JBks3AFuDRlW7fYiUJcBfwVFV9qm/R2O3f2fo68n076jPcy3TWfCe9M+XfBv5w1O1Zhv79Kr2z/N8Cjp3pI/BG4EHgGeBrwEWjbusi+/d5em97/x+9cc0bZ+sbvas6Pt329ePA9lG3f0j9/fPWn6MtDC7tW/8PW3+fBq4ddfsX2Nd30Bu6OQocaV87x3H/ztHXke5b/w2DJHXIOA7vSJJmYehLUocY+pLUIYa+JHWIoS9JHWLoS1KHGPqS1CH/HzjePwMUTRYVAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import cv2 as cv\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "img = cv.imread('../data/sudoku.png',0)\n",
    "equ = cv.equalizeHist(img)\n",
    "\n",
    "histSize = 256\n",
    "ranges   = [0,256]\n",
    "plt.hist(img.ravel(), histSize,ranges)\n",
    "plt.show()\n",
    "plt.hist(equ.ravel(), histSize,ranges)\n",
    "plt.show()\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "f01e5536",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2 as cv\n",
    "import numpy as np\n",
    "\n",
    "img = cv.imread('../data/tsukuba_l.png',0)\n",
    "equ = cv.equalizeHist(img)\n",
    "res = np.hstack((img,equ)) #stacking images side-by-side\n",
    "# cv.imwrite('res.png',res)\n",
    "\n",
    "cv.imshow(\"res\", res)\n",
    "cv.waitKey(0)\n",
    "\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "e2a13994",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import cv2 as cv\n",
    "\n",
    "img = cv.imread('../data/tsukuba_l.png',0)\n",
    "# create a CLAHE object (Arguments are optional).\n",
    "clahe = cv.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))\n",
    "cl1 = clahe.apply(img)\n",
    "# cv.imwrite('clahe_2.jpg',cl1)\n",
    "\n",
    "res = np.hstack((img,cl1))\n",
    "cv.imshow(\"res\", res)\n",
    "cv.waitKey(0)\n",
    "\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d82d2349",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
